#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cassert>
//#include <string>
#include <cstring>
#define LL long long
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
using namespace std;

int n, m, c, TSIZE;
LL tree[(1 << 19) + 1];
LL add[(1 << 19) + 1];
int type[250010], q[250010], v[250010], u[250010], k[250010];
vector <int> all;
char s[200];


inline void Load()
{
	cin >> n >> m >> c;
	nextLine();
	int i;
	int state = 0;
	int num, j;
	bool was;
	for (i = 0; i < m; i++)
	{
		gets(s);
		state = 0;
		was = 0;
		num = 0;
		for (j = 0; s[j] != 0; j++)
		{
			if (s[j] == 'Q')
				type[i] = 0;
			else if (s[j] == 'S')
				type[i] = 1;
			else if (s[j] >= '0' && s[j] <= '9') 
			{
				was = 1;
				num = num * 10 + s[j] - '0';
			}
			else 
			{
			//	cerr << num << "\n";
				if (type[i] == 0)
				{
					if (was)
					{
						q[i] = num;
						all.push_back(num);
				//		cerr << i << " : " << q[i] << "\n";
						state++;
						break;
					}
				}
				else if (type[i] == 1)
				{
					if (was)
					{
						if (state == 0)
							u[i] = num;
						else if (state == 1)
							v[i] = num;
						else if (state == 2)
						{
							k[i] = num;
				//			cerr << i << " : " << u[i] << " " << v[i] << " " << k[i] << "\n";
							state++;
							break;
						}
						state++;
				   	}
				}
				was = 0;
				num = 0;
			}
		}
		if (type[i] == 0 && state == 0)
		{
			q[i] = num;
			all.push_back(num);
		}
		else if (type[i] == 1 && state == 2)
			k[i] = num;
		/*
		c = getchar();
		while (c != 'Q' && c != 'S' && c != EOF) c = getchar();
		if (c == 'Q')
		{
			scanf("%d", &q[i]);
			type[i] = 0;
			all.push_back(q[i]);
		}
		else if (c == 'S')
		{
			scanf("%d%d%d", &u[i], &v[i], &k[i]);
			type[i] = 1;
		}
		*/
	}
	sort(all.begin(), all.end());
	all.erase(unique(all.begin(), all.end()), all.end());

	TSIZE = 1;
	while (TSIZE < all.size()) TSIZE <<= 1;
	for (i = 0; i < all.size(); i++)
	{
		tree[TSIZE + i] = ::c;
	}
	for (i = TSIZE - 1; i >= 1; i--)
	{
		tree[i] = tree[i << 1] + tree[(i << 1) | 1];
	}
}

inline void upd(int v, int L, int R)
{
	if (!add[v]) return;
	tree[v] += ((LL)R - L + 1) * add[v];
	if (v < TSIZE && add[v])
	{
		add[v << 1] += add[v];
		add[(v << 1) | 1] += add[v];
	}
	add[v] = 0;
}

inline void addRange(int v, int k, int l, int r, int L, int R)
{
	if (r < L || R < l) return;
	if (l <= L && r >= R)
	{
		add[v] += k;
		return;
	}
	upd(v, L, R);
	tree[v] += (min(r, R) - max(l, L) + 1) * (LL)k;
	addRange(v << 1, k, l, r, L, (L + R) >> 1);
	addRange((v << 1) | 1, k, l, r, (L+R) / 2 + 1, R);
}

int find(int key)
{
	int mid, l = 0, r = all.size() - 1;
	while (l <= r)
	{
		mid = (l + r) / 2;
		if (all[mid] == key)
			return mid;
		else if (all[mid] < key)
			l = mid + 1;
		else r = mid - 1;
	}
	return -1;
}

int findLeft(int key)
{
	int l = 0;
	int r = all.size() - 1;
	int mid, res = -1;
	while (l <= r)
	{
		mid = (l + r) / 2;
		if (all[mid] >= key)
		{
			res = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	return res;
}

int findRight(int key)
{
	int l = 0;
	int r = all.size() - 1;
	int mid, res = -1;
	while (l <= r)
	{
		mid = (l + r) / 2;
		if (all[mid] <= key)
		{
			res = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	return res;
}

void Solve()
{
	int x, l, r;
	int v;
	int L, R;
	for (int i = 0; i < m; i++)
	{
		if (type[i] == 0)
		{
			x = find(q[i]);
			v = 1;
			L = 0, R = TSIZE - 1;
			while (true)
			{
				upd(v, L, R);
				if (v >= TSIZE)
				{
					printf("%lld\n", tree[v]);
					break;
				}
				if (x <= ((L + R) >> 1))
				{
					v <<= 1;
					R = (L + R) >> 1;
				}
				else
				{
					v = (v << 1) | 1;
					L = (L + R) >> 1;
					L++;
				}
			}
		}
		else
		{
			l = findLeft(u[i]);
			if (l == -1) continue;
			r = findRight(::v[i]);
			if (r == -1) continue;
			addRange(1, k[i], l, r, 0, TSIZE - 1);
		}
	}	
}

#define file "gravel"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file"2.out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}
